<?php

function json($code=0,$message='',$data= []) {
    $ret = [
        'code'=>$code,
        'message'=>$message,
        'data'=>$data
    ];
    exit (json_encode ($ret,JSON_UNESCAPED_UNICODE));

}
//

if (!empty($_FILES['pic'])){
    //2.上传新的
    $file=$_FILES['pic'];
    move_uploaded_file($file['tmp_name'],'../uploads/'.$file['name']);
    $icon=$file['name'];
    json(1,'上传成功',['path'=>$icon]);
}else{
    json(-1,'图片不存在！');
}